﻿namespace Armon.Lib.Type
{
    public static class ObjectExtension
    {
        public static string ToQueryString(this object o) 
        {
            var s = o.GetType().GetProperties().Select(p => $"{p.Name}={p.GetValue(o)}");
            return string.Join("&", s);
        }

        public static Dictionary<string, object?> ToDictionary(this object o)
        {
            return o.GetType()
                .GetProperties()
                .ToDictionary(p => p.Name, p => p.GetValue(o));
        }
    }
}
